package com.shelpe.services.sinbad.repository.jpa;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

import com.shelpe.services.sinbad.entity.jpa.Campaign;

public interface CampaignRepository extends CrudRepository<Campaign, Long>, JpaSpecificationExecutor<Campaign> {

	int countByUserID(long userID);

	List<Campaign> findByUserID(long userID);

	List<Campaign> findByUserIDIn(List<Long> userIDs);

	List<Campaign> findByAutoIDIn(List<Long> autoIDs);

	@Query("select concat(po.autoID, '-', po.title) from com.shelpe.services.sinbad.entity.jpa.Campaign po where po.userID = ?")
	List<String> findCampaignIDsAndName(long userID);
	
	@Query("select distinct po.autoID from com.shelpe.services.sinbad.entity.jpa.Campaign po where po.userID in :ids")
	List<Long> findCampaignIDsByUserIDs(@Param("ids")List<Long> userIDs);
}